/* ****************************************************************************
atlight.h
-------------------------------------------------------------------------------

Copyright (c) 2017, Tain L.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

**************************************************************************** */

#if !defined(SPEARS_ASSET_ATLIGHT_H)
#define SPEARS_ASSET_ATLIGHT_H

#include "my-prerequisites.h"
#include "atsceneobj.h"

namespace Spears
{
	namespace Asset
	{
		class atLight : public atSceneObject
		{
		public:
			enum LightType : unsigned int
			{
				  Unknown = 0
				, Point
				, Spot
				, Area
				, Directional
				, Ambient
			};
		public:
			atLight();
			virtual ~atLight();

		public:
			virtual ObjectType my_type() const override;

		public:
			static LightType _string_to_type(const std::string& type);
			static std::string _type_to_string(const LightType& type);

		public:
			std::string		m_name;

			atPoint			m_position;
			atVector		m_direction;
			atVector		m_up;
			atColor			m_ambient;
			atColor			m_diffuse;
			atColor			m_specular;
			LightType		m_type;
			Math::decimal	m_angle_inner_cone;
			Math::decimal	m_angle_outer_cone;
			Math::decimal	m_attenuation_constant;
			Math::decimal	m_attenuation_linear;
			Math::decimal	m_attenuation_quadratic;
		};

		inline atLight::atLight()
		{}

		inline atLight::~atLight()
		{}

		inline atSceneObject::ObjectType atLight::my_type() const
		{
			return ObjectType::Light;
		}

		inline atLight::LightType atLight::_string_to_type(const std::string& type)
		{
			if (type == "ambient")
				return LightType::Ambient;
			else if (type == "area")
				return LightType::Area;
			else if (type == "directional")
				return LightType::Directional;
			else if (type == "point")
				return LightType::Point;
			else if (type == "spot")
				return LightType::Spot;
			else
				return LightType::Unknown;
		}

		inline std::string atLight::_type_to_string(const atLight::LightType& type)
		{
			switch (type)
			{
			case Asset::atLight::LightType::Ambient:
				return "ambient";

			case Asset::atLight::LightType::Area:
				return "area";

			case Asset::atLight::LightType::Directional:
				return"directional";

			case Asset::atLight::LightType::Point:
				return "point";

			case Asset::atLight::LightType::Spot:
				return "spot";

			default:
				return "unknown";
			}
		}
	} // namespace Asset
} //namespace Spears

#endif // SPEARS_ASSET_ATLIGHT_H